/**
 * 
 */
package belote.webapp.jsf.facelet;

import java.net.URL;

import com.sun.faces.facelets.impl.DefaultResourceResolver;

/**
 * @author Gwenn
 *
 */
public class CustomResourceResolver extends DefaultResourceResolver {

	@Override
	public URL resolveUrl(String path) {
		
		URL url = super.resolveUrl(path);
		
		if (url == null) {
			url = super.resolveUrl("/WEB-INF/jsf" + path);
		}
		
		if (url == null) {
			url = super.resolveUrl("/WEB-INF/jsf/pages" + path);
		}
		
		if (url == null) {
			if (path.startsWith("/")) {
				path = path.substring(1);
			}
			url = Thread.currentThread().getContextClassLoader().getResource(path);
		}
		
		return url;
	}
}
